package com.example.wlt.personnel_manegement_system.Adapter;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.wlt.personnel_manegement_system.Item.Item_task;
import com.example.wlt.personnel_manegement_system.R;

import java.util.List;

/**
 * Created by WLT on 2016/5/18.
 */
public class TaskAdapter extends BaseAdapter {
    private List<Item_task> mList;
    private LayoutInflater mInflater;
    private Activity activity;
    public TaskAdapter(Activity activity, Context context, List<Item_task> List){
        mList=List;
        mInflater=LayoutInflater.from(context);
        this.activity=activity;
    }
    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder holder=null;
        if(convertView == null){
            holder=new ViewHolder();
            convertView=mInflater.inflate(R.layout.task_history_item,null);
            holder.taskname=(TextView)convertView.findViewById(R.id.tv_taskhistory_taskname);
            convertView.setTag(holder);
        }else {
            holder=(ViewHolder)convertView.getTag();
        }
       Item_task mItem=mList.get(position);
        holder.taskname.setText(mItem.taskname);
        final ViewHolder finalHolder = holder;
        return convertView;
    }

    class ViewHolder{
        protected TextView taskname;

    }
}
